import IBulletinVO from '@/model/vo/bulletin/IBulletinVO'
import { getNameByValueAndDictList } from '@/util/CommonUtil'
import { IconRadio } from '@douyinfe/semi-icons'
import { Space } from '@douyinfe/semi-ui'
import { OptionProps } from '@douyinfe/semi-ui/lib/es/select'

export default (dictList: OptionProps[]) => [
  {
    title: '公告类型',
    dataIndex: 'type',
    render: (text: any, record: IBulletinVO, index: number) => {
      return getNameByValueAndDictList(dictList, record.type!)
    },
  },
  { title: '标题', dataIndex: 'title' },
  { title: '公告内容', dataIndex: 'content' },
  { title: '发布时间', dataIndex: 'sendTime', sorter: true },
  {
    title: '状态',
    dataIndex: 'status',
    render: (text: any, record: IBulletinVO, index: number) => {
      const sendFlag = new Date(record.sendTime!) <= new Date() // 是否已经到了发布时间
      return (
        <Space>
          <IconRadio
            className={
              record.status === 1 ? 'warning' : sendFlag ? 'green' : 'cyan-5'
            }
          />
          {record.status === 1 ? '草稿' : sendFlag ? '正式（已发布）' : '正式（待发布）'}
        </Space>
      )
    },
  },
  { title: '创建人', dataIndex: 'createUserName' },
  { title: '创建时间', dataIndex: 'createTime', sorter: true },
]
